﻿//Created by Action Script Viewer - http://www.buraks.com/asv
package Display.CopsBanditsUI {
    import flash.events.*;
    import flash.display.*;
    import flash.utils.*;
    import Display.DialogUI.*;
    import org.aswing.*;
    import Classes.*;
    import org.aswing.geom.*;
    import Modules.bandits.*;
    import ZLocalization.*;
    import Display.*;
    import Display.ValentineUI.*;
    import flash.text.*;
    import Display.aswingui.*;

    public class CopsDialogView extends GenericDialogView {

        public static const TAB_STATE_SELECTED:int = 0;
        public static const TAB_STATE_UNSELECTED:int = 1;
        public static const TAB_WIDTH:int = 221;
        public static const TAB_HEIGHT:int = 37;
        public static const TAB_CAP_FONT_SIZE:int = 22;
        public static const TAB_FONT_SIZE:int = 16;

        protected var m_contentPanel:JPanel;
        protected var m_items:Array;
        protected var m_tabStates:Array;
        protected var m_tabs:Array;
        protected var m_dataDict:Dictionary;
        protected var m_makerPanel:MakerPanel;
        protected var m_officersPanel:OfficersPanel;

        public function CopsDialogView(_arg1:Dictionary, _arg2:String="", _arg3:String="", _arg4:int=0, _arg5:Function=null, _arg6:String="", _arg7:int=0, _arg8:String="", _arg9:Function=null, _arg10:String=""){
            super(_arg1, _arg2, _arg3, _arg4, _arg5, _arg6, _arg7, _arg8, _arg9, _arg10);
            this.setLayout(new SoftBoxLayout(SoftBoxLayout.Y_AXIS));
        }
        override protected function createTitlePanel():JPanel{
            var _local1:JPanel = ASwingHelper.makeSoftBoxJPanel(SoftBoxLayout.CENTER);
            m_titleFontSize = TextFieldUtil.getLocaleFontSize(30, 20, null);
            var _local2:String = this.getTitleString();
            title = ASwingHelper.makeTextField(_local2, EmbeddedArt.TITLE_FONT, m_titleFontSize, EmbeddedArt.titleColor, 3);
            title.filters = EmbeddedArt.newtitleFilters;
            var _local3:TextFormat = new TextFormat();
            _local3.size = m_titleSmallCapsFontSize;
            TextFieldUtil.formatSmallCaps(title.getTextField(), _local3);
            _local1.append(title);
            title.getTextField().height = (m_titleFontSize * 1.5);
            ASwingHelper.setEasyBorder(_local1, 4);
            return (_local1);
        }
        protected function getTitleString():String{
            var _local1:String = ZLoc.t("Dialogs", (m_titleString + "_title"), {amount:String(BanditUtil.getPoliceStationLevel())});
            return (_local1);
        }
        override protected function init():void{
            m_bgAsset = m_assetDict["dialog_bg"];
            m_titleSmallCapsFontSize = 38;
            this.m_tabStates = new Array();
            this.m_tabStates.push(CopsDialog.assetDict["tab_selected"]);
            this.m_tabStates.push(CopsDialog.assetDict["tab_unselected"]);
            this.m_dataDict = Global.gameSettings.getValentinesAssets();
            this.makeBackground();
            this.makeCenterPanel();
            BanditUtil.logDialogStats("view", "station_ui");
            ASwingHelper.prepare(this);
        }
        override protected function makeBackground():void{
            if (m_bgAsset){
                ASwingHelper.setBackground(this, m_bgAsset);
            };
        }
        override protected function makeCenterPanel():void{
            ASwingHelper.setBackground(this, m_bgAsset);
            this.m_contentPanel = ASwingHelper.makeSoftBoxJPanel(SoftBoxLayout.CENTER);
            this.append(createHeaderPanel());
            this.append(this.makeTabsPanel());
            this.append(ASwingHelper.verticalStrut(-3));
            this.append(this.makeSubHeadPanel());
            this.append(this.m_contentPanel);
            this.append(ASwingHelper.verticalStrut(14));
            ASwingHelper.prepare(this);
        }
        protected function makeSubHeadPanel():JPanel{
            var _local1:JPanel = ASwingHelper.makeFlowJPanel(FlowLayout.CENTER);
            var _local2:JPanel = ASwingHelper.makeFlowJPanel(FlowLayout.CENTER, 80);
            ASwingHelper.setEasyBorder(_local1, 0, 10, 0, 10);
            var _local3:Sprite = new Sprite();
            _local3.graphics.beginFill(EmbeddedArt.whiteTextColor);
            _local3.graphics.drawRect(0, 0, 670, 50);
            _local3.graphics.endFill();
            ASwingHelper.setBackground(_local1, _local3);
            var _local4:JPanel = ASwingHelper.makeFlowJPanel(FlowLayout.LEFT);
            var _local5:AssetPane = new AssetPane((new (CopsDialog.assetDict["police_doughnut"])() as DisplayObject));
            var _local6:JLabel = ASwingHelper.makeLabel("sppoooon", EmbeddedArt.DEFAULT_FONT_NAME_BOLD, 36, EmbeddedArt.lightOrangeTextColor);
            var _local7:JLabel = ASwingHelper.makeLabel(ZLoc.t("Dialogs", "BanditsUI_donuts"), EmbeddedArt.DEFAULT_FONT_NAME_BOLD, 14, EmbeddedArt.brownTextColor);
            _local4.appendAll(_local5, _local6, _local7);
            var _local8:JPanel = ASwingHelper.makeFlowJPanel(FlowLayout.LEFT);
            var _local9:AssetPane = this.createIcon();
            var _local10:String = this.getSubHeadPanelLocaliztionString();
            var _local11:JLabel = ASwingHelper.makeLabel(this.getSubHeadPanelData(), EmbeddedArt.TITLE_FONT, 36, EmbeddedArt.lightOrangeTextColor);
            var _local12:AssetPane = ASwingHelper.makeMultilineText(_local10, 150, EmbeddedArt.DEFAULT_FONT_NAME_BOLD, TextFormatAlign.LEFT, 14, EmbeddedArt.brownTextColor);
            _local8.appendAll(_local9, _local11, _local12);
            _local2.appendAll(ASwingHelper.horizontalStrut(20), _local8, ASwingHelper.horizontalStrut(20));
            _local1.append(_local2);
            return (_local1);
        }
        protected function createIcon():AssetPane{
            return (new AssetPane((new (CopsDialog.assetDict["police_bandit"])() as DisplayObject)));
        }
        protected function getSubHeadPanelData():String{
            return (String(BanditManager.numBanditsCaptured));
        }
        protected function getSubHeadPanelLocaliztionString():String{
            var _local1:LocalizationObjectToken = ZLoc.tk("Dialogs", "Bandit", "", BanditManager.numBanditsCaptured);
            var _local2:String = ZLoc.t("Dialogs", "BanditsUI_banditscaught", {bandit:_local1}).toUpperCase();
            return (_local2);
        }
        protected function makeTabsPanel():JPanel{
            var _local3:JPanel;
            var _local4:JPanel;
            var _local5:JTextField;
            var _local6:TextFormat;
            var _local1:JPanel = ASwingHelper.makeSoftBoxJPanel(SoftBoxLayout.CENTER, 4);
            this.m_tabs = [ASwingHelper.makeSoftBoxJPanelVertical(SoftBoxLayout.CENTER), ASwingHelper.makeSoftBoxJPanelVertical(SoftBoxLayout.CENTER), ASwingHelper.makeSoftBoxJPanelVertical(SoftBoxLayout.CENTER)];
            var _local2:int;
            while (_local2 < this.m_tabs.length) {
                _local3 = this.m_tabs[_local2];
                _local3.setPreferredSize(new IntDimension(TAB_WIDTH, TAB_HEIGHT));
                _local3.setMinimumSize(new IntDimension(TAB_WIDTH, TAB_HEIGHT));
                _local3.setMaximumSize(new IntDimension(TAB_WIDTH, TAB_HEIGHT));
                _local4 = ASwingHelper.makeSoftBoxJPanel(SoftBoxLayout.CENTER);
                _local5 = ASwingHelper.makeTextField(ZLoc.t("Dialogs", ("Bandits_TabLabel_" + _local2)), EmbeddedArt.TITLE_FONT, TAB_FONT_SIZE, EmbeddedArt.blueTextColor);
                _local6 = new TextFormat();
                _local6.size = TAB_CAP_FONT_SIZE;
                TextFieldUtil.formatSmallCaps(_local5.getTextField(), _local6);
                _local4.append(_local5);
                _local5.getTextField().height = (TAB_FONT_SIZE * 1.5);
                _local3.append(_local4);
                _local1.append(_local3);
                _local3.addEventListener(MouseEvent.MOUSE_UP, this.onTabClicked, false, 0, true);
                _local2++;
            };
            this.setSelectedTab(CopsDialog.DEFAULT_TAB, false);
            ASwingHelper.setEasyBorder(_local1, 0, 10, 0, 10);
            return (_local1);
        }
        protected function createContentPanel(_arg1:String):JPanel{
            var _local2:JPanel = ASwingHelper.makeFlowJPanel();
            var _local3:JLabel = ASwingHelper.makeLabel(_arg1, EmbeddedArt.DEFAULT_FONT_NAME_BOLD, 36, EmbeddedArt.redTextColor);
            _local2.append(_local3);
            return (_local2);
        }
        protected function createOfficersPanel():JPanel{
            this.m_officersPanel = new OfficersPanel();
            this.m_officersPanel.addEventListener(MakerPanel.PREPARE, this.preparePane, false, 0, true);
            return (this.m_officersPanel);
        }
        protected function createBanditsPanel():JPanel{
            var _local1:BanditsPanel = new BanditsPanel();
            _local1.addEventListener(MakerPanel.PREPARE, this.preparePane, false, 0, true);
            return (_local1);
        }
        protected function createUpgradesPanel():JPanel{
            var _local1:UpgradesPanel = new UpgradesPanel();
            _local1.addEventListener(UpgradesPanel.PREPARE, this.preparePane, false, 0, true);
            return (_local1);
        }
        protected function preparePane(_arg1:Event):void{
            ASwingHelper.prepare(this.parent);
        }
        public function setSelectedTab(_arg1:int, _arg2:Boolean):void{
            var _local3:JPanel;
            for each (_local3 in this.m_tabs) {
                _local3.setBackgroundDecorator(new AssetBackground((new (this.m_tabStates[TAB_STATE_UNSELECTED])() as DisplayObject)));
            };
            this.m_tabs[_arg1].setBackgroundDecorator(new AssetBackground((new (this.m_tabStates[TAB_STATE_SELECTED])() as DisplayObject)));
            this.m_contentPanel.removeAll();
            switch (_arg1){
                case CopsDialog.TAB_OFFICERS:
                    this.m_contentPanel.appendAll(this.createOfficersPanel());
                    break;
                case CopsDialog.TAB_BANDITS:
                    this.m_contentPanel.appendAll(this.createBanditsPanel());
                    break;
                case CopsDialog.TAB_UPGRADES:
                    this.m_contentPanel.appendAll(this.createUpgradesPanel());
                    break;
            };
            ASwingHelper.prepare(this.parent);
        }
        protected function onTabClicked(_arg1:MouseEvent):void{
            var _local2:int;
            while (_local2 < this.m_tabs.length) {
                if (this.m_tabs[_local2] == _arg1.currentTarget){
                    this.setSelectedTab(_local2, true);
                    BanditUtil.logDialogStats(CopsDialog.STATS_TAB_NAMES[_local2], "station_ui");
                    break;
                };
                _local2++;
            };
        }
        override protected function onCancelX(_arg1):void{
            super.onCancelX(_arg1);
            BanditUtil.logDialogStats("X", "station_ui");
        }

    }
}//package Display.CopsBanditsUI 
